import request from '@/utils/request'
/**
 * 列表
 * @param {*} data
 */
export function crmRoiIndexAPI(data) {
  return request({
    url: 'crmPutinMoney/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/** ---------------加盟商列表-------------------- */
/**
 * 列表
 * @param {*} data
 */
 export function crmPutinAllianceBusinessAPI(data) {
  return request({
    url: 'crmPutinAllianceBusiness/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 投放金额导出
 * @param {*} data
 *
 */
export function crmRoiExcelExportAPI(data) {
  return request({
    url: 'crmPutinMoney/batchExportExcel',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}
/**
 * 投放金额全部导出
 * @param {*} data
 */
export function crmRoiExcelAllExportAPI(data) {
  return request({
    url: 'crmPutinMoney/allExportExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
/**
 * 新建 编辑
 * @param {*} data
 */
export function crmRoiSaveAPI(data) {
  const url = data.entity && data.entity.leadsId ? 'update' : 'add'
  return request({
    url: 'crmPutinMoney/' + url,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
/**
 * 获取平台列表
 * @param {*} data
 */
export function crmPutinMoneySourceAPI() {
  return request({
    url: 'crmPutinMoney/querySource',
    method: 'post',
    data: {},
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
/**
 * 投放金额导入
 * @param {*} data
 *
 */
export function crmRoiExcelImportAPI(data) {
  var param = new FormData()
  Object.keys(data).forEach(key => {
    param.append(key, data[key])
  })
  return request({
    url: 'crmPutinMoney/uploadExcel',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 投放金额模板下载
 * @param {*} data
 *
 */
export const crmRoiExcelDownloadURL = process.env.BASE_API + 'crmPutinMoney/downloadExcel'
export function crmRoiDownloadExcelAPI(data) {
  return request({
    url: 'crmPutinMoney/downloadExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

/**
 * 删除
 * @param {*} data
 */
export function crmroiDeleteAPI(data) {
  return request({
    url: 'crmPutinMoney/deleteByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 删除
 * @param {*} data
 */
export function crmAllianceBusinessDeleteAPI(data) {
  return request({
    url: 'crmPutinAllianceBusiness/deleteByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 查看详情
 * @param {*} data
 */
 export function crmroiQueryByIdAPI(data) {
  return request({
    url: `crmPutinMoney/queryListById/${data}`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
